home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / lib / scribus-ng / import.prolog
Encoding:
Text File  |  2009-05-08  |  32.7 KB  |  1,495 lines

  1. %
  2. % psi.prolog
  3. %
  4. % Copyright (C) 1996-2000 by vhf computer GmbH + vhf interservice GmbH
  5. % Author:   Georg Fleischmann
  6. %
  7. % created:  2000-09-09
  8. % modified: 
  9. %
  10.  
  11. %%% this file also contains a section taken from GPL Ghostscript 8.50 "traceimg.ps", see below
  12.  
  13. % this PostScript code writes a file with the structure below.
  14. % # # # # l        (x0 y0 x1 y1) line
  15. % # # # # # # # #c    (x0 y0 x1 y1 x2 y2 x3 y3) curve
  16. % # w            (width) width
  17. % # # # # # co        (c m y k a) color
  18. % n            new list
  19. % f            list is a filled polygon
  20. % s            list is a group
  21. % cl            list is a clip list (clip with old clip list and use it)
  22. % gs            save current clip list and width to top of stack
  23. % gr            use last clip list (on top of stack) and width
  24. % # # # # # # # # # #    (x y a b c d e f text font) text
  25. %
  26. % Adapted for Scribus by Franz Schmid 15.05.2004
  27. % Also removed the hardcoded Output Filename
  28. % and changed it in a way the -sOutputFile Option of Ghostscript can be used
  29. % Speeded up the flattening of Text by removing unneeded calculations.
  30. % Changed the Output slightly to ease parsing
  31. % m                 moveto  
  32. % l # # # #         (x0 y0 x1 y1) line
  33. % c # # # # # # # # (x0 y0 x1 y1 x2 y2 x3 y3) curve
  34. % w #               (width) Linewidth
  35. % co # # # # #      (c m y k a) color
  36. % n                 new list
  37. % f                 list is a filled polygon
  38. % s                 list is a stroke path
  39. % cp                close current subpath
  40. % ci                list is a clip list (clip with old clip list and use it)
  41. % sp                end of page
  42. % lj #              linejoin
  43. % lc #              linecap
  44. % ld # # #n         linedash count offset d1, d2, dx
  45. % im #              image <name>
  46. % pat # #           makepattern params tmpfilename
  47. % mask                imagemask, followed by b/w image
  48. % fill-evenodd        set fill rule
  49. % fill-winding        - " -
  50. % 15.05.2004 Added the Glyphshow Operator.
  51. % 17.05.2004 Made clipping working.
  52. % 20.05.2004 kshow is working now.
  53. % 22.02.2006 added image and colorimage ops -- av
  54. % 02.03.2006 added code to divide reported coordinates by (device resolution/72) -- av
  55. % 23.03.2006 added code to trace PDF commands
  56.  
  57. % some hacks to get access to PDF operators, needs -sDELAYBIND
  58.  
  59. currentglobal true setglobal
  60. GS_PDF_ProcSet begin
  61. currentdict /setshowstate
  62. {
  63.     dup WordSpacing 0 32 TextSpacing 0 6 -1 roll awidthshow
  64.     //setshowstate exec
  65. } .forceput 
  66. currentdict /endpage {
  67.     (sp\n) print
  68.     //endpage exec
  69. } .forceput
  70. currentdict /doimage known not {
  71.     currentdict /doimage { } .forceput
  72. } if
  73. currentdict /doimage {
  74.     currentdict i_image
  75.     //doimage exec
  76. } .forceput
  77. end
  78. setglobal
  79. .bindnow
  80.  
  81. /cfile TraceFile (w) file def
  82. /print { cfile exch writestring } bind def
  83.  
  84.  
  85. /==write  % any ==write -
  86.     dup type dup /arraytype eq exch /packedarraytype eq or
  87.     { 
  88.         i_file ([) writestring 
  89.             { ==write i_file ( ) writestring } forall 
  90.         i_file (]) writestring
  91.     } {
  92.     dup type /nametype eq
  93.     {
  94.         i_file (/) writestring i_file exch i_str cvs writestring
  95.     } {
  96.     dup type /stringtype eq
  97.     {
  98.         true 1 index { 32 ge and } forall
  99.         {
  100.             i_file (\() writestring i_file exch writestring i_file (\)) writestring
  101.         }
  102.         {
  103.             i_file (<) writestring
  104.             i_file /ASCIIHexEncode filter dup
  105.             3 -1 roll
  106.             writestring closefile % close filter 
  107.             i_file (\n) writestring            
  108.         } ifelse
  109.     } {
  110.     dup type /dicttype eq
  111.     {
  112.         i_file (<<) writestring
  113.         { ==write ( ) =write ==write (\n) =write } forall
  114.         i_file (>>) writestring
  115.     } {
  116.         i_file exch i_str cvs
  117.         dup dup length 1 sub get (-) 0 get eq { pop (null) } if 
  118.         writestring
  119.     } ifelse } ifelse } ifelse } ifelse
  120. } def
  121.  
  122. /=write  % any =write -
  123.     dup type dup /arraytype eq exch /packedarraytype eq or
  124.     { 
  125.             { =write i_file ( ) writestring } forall 
  126.     } {
  127.     dup type /nametype eq
  128.     {
  129.         i_file exch i_str cvs writestring
  130.     } {
  131.     dup type /stringtype eq
  132.     {
  133.         i_file exch writestring
  134.     } {
  135.     dup type /dicttype eq
  136.     {
  137.         i_file (<<) writestring
  138.         { =write ( ) =write =write (\n) =write } forall
  139.         i_file (>>) writestring
  140.     } {
  141.         i_file exch i_str cvs writestring
  142.     } ifelse } ifelse } ifelse } ifelse
  143. } def
  144.  
  145.  
  146. % flag to deactivate our substitutions
  147. /i_shortcut false def
  148.  
  149. % defines an overloaded function     name proc i_shortcutOverload -
  150. % equvalent to /name { i_shortcut { //name } { proc } ifelse } bind def
  151. /i_shortcutOverload
  152. {
  153.     [ /i_shortcut /load load [ 5 index load ] cvx 4 index /ifelse load ] cvx 
  154.     exch pop 
  155.     bind def
  156. } def
  157.  
  158. % whether we have to flatten the text
  159. /flattenText 1 def
  160.  
  161. % is a Clipping there
  162. /clipCnt 0 def
  163.  
  164. % remember the current point
  165. /currentX 0 def
  166. /currentY 0 def
  167.  
  168. % 1st point of path to close the path
  169. /beginX 0 def
  170. /beginY 0 def
  171.  
  172. % dummy for converting strings
  173. /i_str 50 string def
  174.  
  175. % 0 = mirror at
  176. /mirror 0 def
  177.  
  178. % mirror a at 0
  179. /mir
  180. {
  181.     mirror 0 ne
  182.     {    0 exch sub
  183.     }if
  184. } bind def
  185.  
  186. % scale
  187.  
  188. currentpagedevice /HWResolution get aload pop
  189. 72 div /i_vscale exch def
  190. 72 div /i_hscale exch def
  191.  
  192. /m_a 1 def
  193. /m_b 0 def
  194. /m_c 0 def
  195. /m_d 1 def
  196. /m_x 0 def
  197. /m_y 0 def
  198. /matrix_x    % x y
  199. {
  200.     % ax + cy + tx
  201.     m_c mul exch m_a mul add m_x add i_hscale div
  202. } bind def
  203. /matrix_y    % x y
  204. {
  205.     % bx + dy + ty
  206.     m_d mul exch m_b mul add m_y add i_vscale div
  207. } bind def
  208.  
  209.  
  210. /concatenate   % str1 str2 concatenate str12
  211. {
  212.     dup length 2 index length add string
  213.     dup 3 index length 3 index putinterval
  214.     dup 0 4 index putinterval
  215.     exch pop exch pop
  216. } bind def 
  217.  
  218. % this is like search but returns the last match in string
  219. /rsearch    % string seek  rsearch  post match pre true // string false
  220. {
  221.     2 copy search    % string seek post1 match1 pre1 true
  222.     {
  223.         2 index 4 index rsearch        % string seek post1 match1 pre1 post2 match2 pre2 true
  224.         {
  225.             6 -1 roll pop            % string seek match1 pre1 post2 match2 pre2 
  226.             % combine (pre1 match1 pre2) into one string
  227.             5 -1 roll exch concatenate    % string seek pre1 post2 match2 (match1+pre2)
  228.             4 -1 roll exch concatenate    % string seek post2 match2 (pre1+match1+pre2)
  229.         } {        % string seek post1 match1 pre1 post1
  230.             pop
  231.         } ifelse
  232.         % string seek post match pre
  233.         5 -2 roll pop pop
  234.         true
  235.     } {        % string seek string 
  236.         pop pop false
  237.     } ifelse
  238. } bind def
  239.  
  240.  
  241. % returns a unique filename for the given extension
  242. /i_exportfilename   % string i_exportfilename string
  243. {
  244.     /ExportFiles where { /ExportFiles get (.) rsearch { exch pop exch pop } if } { (imagefile) } ifelse
  245.         (-) concatenate dup /i_basename exch def i_filecount 9 string cvs concatenate
  246.         {
  247.             i_filecount 1 add /i_filecount exch store
  248.             dup 2 index concatenate status not { exit } if
  249.             pop pop pop pop pop
  250.             i_basename i_filecount 9 string cvs concatenate
  251.         } loop
  252.     exch pop
  253. } bind def
  254.  
  255. % Code for reading patters is currently commented out, as it
  256. % doesn't seem to work correctly.
  257. % /makepattern { % dict matrix  makepattern patterndict
  258. % %/makepattern =
  259. %     % we will do some real painting here:
  260. %     /i_shortcut true store
  261. %     % params:
  262. %     /i_m exch def
  263. %     /i_dict exch def
  264. %     % define export filename    
  265. %     /i_basename (.png) i_exportfilename (.png) concatenate def
  266. %     i_dict /BBox get
  267. %         dup 0 get /i_x exch def
  268. %         dup 1 get /i_y exch def
  269. %         dup 2 get i_x sub /i_w exch def
  270. %         3 get i_y sub /i_h exch def
  271. %     % we want those in devspace:
  272. %         i_x i_y i_m itransform matrix currentmatrix transform
  273. %             i_vscale div /i_y exch def i_hscale div /i_x exch def
  274. %         i_w i_h i_m idtransform matrix currentmatrix dtransform
  275. %             i_vscale div /i_h exch def i_hscale div /i_w exch def
  276. %         % i_h < 0 ?
  277. %         i_h 0 le
  278. %         {
  279. %             /i_y i_h i_y add def
  280. %             /i_h i_h neg def
  281. %         } if
  282. %         % i_w < 0 ?
  283. %         i_w 0 le
  284. %         {
  285. %             /i_x i_w i_x add def
  286. %             /i_w i_w neg def
  287. %         } if
  288. %     % now we can use the current matrix as pattern matrix, but with (0,0) origin
  289. %     i_m ==
  290. %     i_x i_y matrix currentmatrix translate /i_m exch def
  291. %     i_m ==
  292. %     i_dict /BBox [ 0 0 i_w i_h ] put 
  293. %     (w x h =) = i_w = i_h =
  294. %     % paint pattern to png file
  295. %     gsave
  296. %     currentcolor currentcolorspace
  297. %     << 
  298. %         /OutputFile i_basename
  299. %         /OutputDevice (pngalpha)
  300. %         /TextAlphaBits 4
  301. %         /GraphicsAlphaBits 4
  302. % %        /BackgroundColor 16777215
  303. % %        /BackgroundColor 0
  304. %         /PageUsesTransparency true
  305. %         /HWResolution [ 72 72 ]
  306. %         /ProcessColorModel /DeviceRGB
  307. %         /PageSize [i_w i_h]
  308. %     /pngalpha finddevice putdeviceprops setdevice 
  309. %     setcolorspace setcolor
  310. % %    matrix currentmatrix ==
  311. % %    0 0 transform exch = =
  312. % %    1 1 transform exch = =
  313. %     i_dict i_w i_h matrix identmatrix scale 
  314. %             %matrix identmatrix 
  315. %             //makepattern setpattern
  316. %     0 0 i_w i_h rectfill
  317. %     showpage
  318. %     grestore
  319. %     % create pattern with our extensions:
  320. %     i_dict dup /ExportFile i_basename put
  321. %     dup /Origin [ 0 0 transform ] put
  322. %     i_m //makepattern
  323. %     /i_shortcut false store
  324. % %/makepatternE =
  325. % } i_shortcutOverload
  326.  
  327. /writecurrentpattern
  328. {
  329.     currentcolor
  330.     (pat ) print
  331.     dup /Origin get
  332.     dup 0 get i_hscale div i_str cvs print ( ) print
  333.         1 get i_vscale div i_str cvs print ( ) print
  334.     /ExportFile get print
  335.     (\n) print
  336. } bind def
  337.  
  338. /writecurrentcmykcolor
  339. {
  340.     currentcmykcolor    % -> c m y k
  341.     (co )print
  342.     3 index i_str cvs print
  343.     ( ) print
  344.     2 index i_str cvs print
  345.     ( ) print
  346.     1 index i_str cvs print
  347.     ( ) print
  348.     i_str cvs print
  349.     ( ) print
  350.     pop pop pop
  351.     .currentopacityalpha    % a
  352.     i_str cvs print
  353.     (\n) print
  354. } bind def
  355.  
  356.  
  357. /writecurrentrgbcolor
  358. {
  359.     currentrgbcolor    % -> r g b
  360.     (corgb )print
  361.     2 index i_str cvs print
  362.     ( ) print
  363.     1 index i_str cvs print
  364.     ( ) print
  365.     i_str cvs print
  366.     ( ) print
  367.     pop pop
  368.     .currentopacityalpha    % a
  369.     i_str cvs print
  370.     (\n) print
  371. } bind def
  372.  
  373.  
  374. /writecurrentcolor
  375. {
  376.     currentcolorspace 0 get 
  377.  
  378.     % try to find a base colorspace first
  379.     dup    /Indexed eq
  380.     {
  381.         pop
  382.         currentcolorspace 1 get
  383.         dup type /arraytype eq { 0 get } if
  384.     } if
  385.  
  386.     dup dup /DeviceN eq exch /Separation eq or
  387.     {
  388.         pop
  389.         currentcolorspace 2 get
  390.         dup type /arraytype eq { 0 get } if
  391.     } if
  392.  
  393.     % now write values
  394.     dup /CIEBasedABC eq
  395.     { % this must be a hack....
  396.         gsave
  397.         currentcolor setrgbcolor
  398.         writecurrentrgbcolor
  399.         grestore
  400.     } {
  401.      dup /DeviceRGB eq
  402.     {
  403.         writecurrentrgbcolor
  404.     } {
  405.     dup dup /DeviceCMYK eq exch /DeviceGray eq or
  406.     {
  407.         writecurrentcmykcolor
  408.     } { 
  409.     dup /Pattern eq
  410.     {
  411.         writecurrentpattern
  412.     } {
  413.         % TODO: other CIE
  414.         writecurrentrgbcolor % will always be 0
  415.     }
  416.     ifelse } ifelse } ifelse } ifelse
  417.     pop
  418. } bind def
  419.  
  420. /writecurrentlinecap
  421. {
  422.     (lc ) print
  423.     currentlinecap i_str cvs print
  424.     (\n) print
  425. } bind def
  426.  
  427. /writecurrentlinejoin
  428. {
  429.     (lj ) print
  430.     currentlinejoin i_str cvs print
  431.     (\n) print
  432. } bind def
  433.  
  434. /writecurrentdash
  435. {
  436.     (ld ) print
  437.     currentdash 1 index length i_str cvs print ( ) print i_str cvs print ( ) print
  438.     0 1 2 index length 1 sub
  439.     {
  440.         1 index exch get
  441.         storeMatrix
  442.         dup dup dup m_b abs mul exch m_d abs mul add  exch m_a abs mul add  exch m_c abs mul add  2 div  abs
  443.         i_hscale div
  444.         i_str cvs print ( ) print
  445.     } for
  446.     pop
  447.     (\n) print
  448. } bind def
  449.  
  450. /writecurrentlinewidth
  451. {
  452.     userdict begin
  453.     currentlinewidth    % w
  454.     storeMatrix
  455.  
  456.     % (wb + wd + wa + wc) / 2
  457. %??    
  458.     dup dup dup m_b abs mul exch m_d abs mul add  exch m_a abs mul add  exch m_c abs mul add  2 div  abs
  459.     i_hscale div
  460.     % transform (w,w) and take length
  461. %av-test:    dup dtransform i_vscale div dup mul exch i_hscale div dup mul add sqrt
  462.     (w ) print
  463.     i_str cvs print
  464.     (\n) print
  465.     end
  466. } bind def
  467.  
  468. /i_move    % x y
  469. {
  470.     userdict begin
  471.     (m\n) print
  472.     /currentY exch def
  473.     /currentX exch def
  474.     /beginX currentX def
  475.     /beginY currentY def
  476.     end
  477. } bind def
  478.  
  479. /i_line
  480. {
  481.     userdict begin
  482.     /y1 exch def
  483.     /x1 exch def
  484.  
  485.     % x x1 ne y y1 ne or
  486.     currentX x1 sub abs 0.001 gt  currentY y1 sub abs 0.001 gt or
  487.     {
  488.         (l ) print
  489.         currentX currentY matrix_x i_str cvs print
  490.         ( ) print
  491.         currentX currentY matrix_y i_str cvs print
  492.         ( ) print
  493.  
  494.         x1 y1 matrix_x i_str cvs print
  495.         ( ) print
  496.         x1 y1 matrix_y i_str cvs print
  497.         (\n) print
  498.         /currentX x1 def
  499.         /currentY y1 def
  500.     }if
  501.     end
  502. } bind def
  503.  
  504. /i_curve
  505. {
  506.     userdict begin
  507.     % x1 y1 x2 y2 x3 y3
  508.     (c ) print
  509.     currentX currentY matrix_x i_str cvs print
  510.     ( ) print
  511.     currentX currentY matrix_y i_str cvs print
  512.     ( ) print
  513.     5 index 5 index matrix_x i_str cvs print
  514.     ( ) print
  515.     5 index 5 index matrix_y i_str cvs print
  516.     ( ) print
  517.     3 index 3 index matrix_x i_str cvs print
  518.     ( ) print
  519.     3 index 3 index matrix_y i_str cvs print
  520.     ( ) print
  521.  
  522.     /currentY exch def
  523.     /currentX exch def
  524.  
  525.     currentX currentY matrix_x i_str cvs print
  526.     ( ) print
  527.     currentX currentY matrix_y i_str cvs print
  528.     (\n)print
  529.     pop pop pop pop
  530.     end
  531. } bind def
  532.  
  533. % modified: 18.10.96
  534. /i_close
  535. {
  536.     beginX beginY i_line
  537.     (cp\n) print
  538. } bind def
  539.  
  540. /storeMatrix
  541. {
  542.     userdict begin
  543.     matrix currentmatrix
  544.     dup 0 get /m_a exch def
  545.     dup 1 get /m_b exch def
  546.     dup 2 get /m_c exch def
  547.     dup 3 get /m_d exch def
  548.     dup 4 get /m_x exch def
  549.     5 get /m_y exch def
  550.     end
  551. } bind def
  552.  
  553. /pathClipAndClose % this is not nice: closes all open paths & flattens the path :-(
  554. {
  555.     clipsave 
  556.     clip                % combine clippath and path
  557.     newpath clippath    % copy (closed) clippath to path
  558.     cliprestore
  559. } bind def
  560.  
  561.  
  562. % find out if the point is within the clipping area
  563. /i_in_clip                    % x y  i_in_clip  bool
  564. {
  565.     gsave
  566.     newpath clippath
  567.     infill
  568.     grestore
  569. } bind def
  570.  
  571.  
  572. % find out if two points are within the clipping area
  573. /i_in_clip2                    % x1 y1 x2 y2 i_in_clip  bool1 bool2
  574. {
  575.     gsave
  576.     newpath clippath
  577.     infill                    % x1 y1 bool2
  578.     3 1 roll                % bool2 x1 y1
  579.     infill                    % bool2 bool1
  580.     exch
  581.     grestore
  582. } bind def
  583.  
  584.  
  585. /i_clip_move
  586. {
  587.     /beginY exch store 
  588.     /beginX exch store 
  589.     /currentX beginX store
  590.     /currentY beginY store
  591.     % test if within cliparea
  592.     currentX currentY i_in_clip
  593.     {
  594.         currentX currentY /moveto load
  595.     } if
  596. } bind def
  597.  
  598.  
  599. % find intersection with line x1,y1 -> x2,y2 with clip path.
  600. % x1,y2 is outside the clip area, x2, y2, x3, y3 inside
  601.  
  602. /i_find_clip_intersect        % x1 y1 x2 y2  i_find_clip_intersect  x3 y3
  603. {
  604.     3 index 2 index sub        % x1 y1 x2 y2 dx
  605.     3 index 2 index sub        % x1 y1 x2 y2 dx dy
  606.     gsave
  607.     newpath clippath
  608.     {
  609.         2 div exch 2 div exch                % half interval
  610.         2 copy abs 0.01 lt exch abs 0.01 lt and
  611.             { exit } if                        % done
  612.         2 copy 4 index add exch                % x1 y1 x2 y2 dx dy (y2+dy) dx
  613.                5 index add exch                % x1 y1 x2 y2 dx dy (x2+dx) (y2+dy)
  614. %        /Intersect = 7 index = 6 index = 5 index = 4 index = 3 index = 2 index = 1 index = 0 index = 
  615.         2 copy infill
  616.         {                                    % replace x2,y2
  617.             6 -2 roll pop pop
  618.             4 2 roll
  619.         } {
  620.             8 -2 roll pop pop                % replace x1,y1
  621.             6 2 roll
  622.         } ifelse
  623.     } loop
  624.     grestore
  625.     6 -2 roll                                % return x2,y2
  626.     4 { pop } repeat
  627. } bind def
  628.  
  629. /i_clip_line
  630. {
  631.     /endY exch store
  632.     /endX exch store
  633.     currentX currentY endX endY i_in_clip2 
  634.     { % end in
  635.         {  
  636.             % both in. just draw it. FIXME check if line leaves cliparea
  637.             endX endY /lineto load
  638.         } {
  639.             % current not in
  640.             % find new current point
  641.             currentX currentY endX endY i_find_clip_intersect 
  642.             /moveto load
  643.             endX endY /lineto load
  644.         } ifelse
  645.     } { % end not in
  646.         {   % current in
  647.             % find new endpoint
  648.             endX endY currentX currentY i_find_clip_intersect 
  649.             /lineto load
  650.         } {
  651.             % both not in
  652.             % try to find a point within cliparea
  653.             currentX currentY endX endY i_find_clip_intersect
  654.             2 copy i_in_clip
  655.             {
  656.                 % yeah
  657.                 /moveto load
  658.                 % now find point from other end
  659.                 endX endY currentX currentY i_find_clip_intersect
  660.                 /lineto load
  661.             } {
  662.                 pop pop
  663.             } ifelse
  664.         } ifelse
  665.     } ifelse
  666.     /currentX endX store
  667.     /currentY endY store
  668. } bind def
  669.  
  670.  
  671. /pathClipForStroke 
  672. {
  673.     % only lines
  674.     flattenpath
  675.     % create a userpath from currentpath
  676.     userdict begin
  677.     /beginX 0 def /beginY 0 def
  678.     /currentX 0 def /currentY 0 def
  679.     /endX 0 def /endY 0 def
  680.     systemdict begin                            % some EPS redefine moveto & Co :-(
  681.     [
  682.             { i_clip_move }                        % remember last move
  683.             { i_clip_line }                        % clip lines individually
  684.             { 6 {pop} repeat /OOPS = }            % won't happen
  685.             { beginX beginY i_clip_line }        % close with line
  686.         pathforall
  687.     ] cvx 
  688. %    dup ==
  689.     newpath % uappend % userpaths SUCK!
  690.     end end
  691.     exec
  692. } bind def
  693.  
  694. /rectfill
  695. {
  696.     userdict begin
  697.     (n\n)print            % start polygon
  698.     writecurrentcolor
  699.     writecurrentlinewidth
  700.     writecurrentlinecap
  701.     writecurrentlinejoin
  702.     writecurrentdash
  703.     storeMatrix
  704.  
  705.     % x y width height
  706.     dup type /arraytype ne
  707.     {
  708.         /hr exch def
  709.         /wr exch def
  710.         /yr exch def
  711.         /xr exch def
  712.         xr yr i_move
  713.         xr wr add yr i_line
  714.         xr wr add yr hr add i_line
  715.         xr yr hr add i_line
  716.         xr yr i_line
  717.     }
  718.     % numarray
  719.     % numstring
  720.     {
  721.         /ar exch def
  722.         0 4 ar length 1 sub
  723.         {
  724.             /n exch def
  725.             ar n get /xr exch def
  726.             ar n 1 add get /yr exch def
  727.             ar n 2 add get /wr exch def
  728.             ar n 3 add get /hr exch def
  729.             xr yr i_move
  730.             xr wr add yr i_line
  731.             xr wr add yr hr add i_line
  732.             xr yr hr add i_line
  733.             xr yr i_line
  734.         } for
  735.     }ifelse
  736.     (cp\n)print
  737.     (f\n)print            % close polygon
  738.     end
  739. } i_shortcutOverload
  740.  
  741. /rectstroke
  742. {
  743.     userdict begin
  744.     (n\n)print            % start rect
  745.     writecurrentcolor
  746.     writecurrentlinewidth
  747.     writecurrentlinecap
  748.     writecurrentlinejoin
  749.     writecurrentdash
  750.     storeMatrix
  751.  
  752.     % x y width height
  753.     dup type dup /arraytype ne exch /stringtype ne and
  754.     {
  755.         /hr exch def
  756.         /wr exch def
  757.         /yr exch def
  758.         /xr exch def
  759.         xr yr i_move
  760.         xr wr add yr i_line
  761.         xr wr add yr hr add i_line
  762.         xr yr hr add i_line
  763.         xr yr i_line
  764.     }
  765.     % numarray
  766.     % numstring
  767.     {
  768.         /ar exch def
  769.         0 4 ar length 1 sub
  770.         {
  771.             /n exch def
  772.             ar n get /xr exch def
  773.             ar n 1 add get /yr exch def
  774.             ar n 2 add get /wr exch def
  775.             ar n 3 add get /hr exch def
  776.             xr yr i_move
  777.             xr wr add yr i_line
  778.             xr wr add yr hr add i_line
  779.             xr yr hr add i_line
  780.             xr yr i_line
  781.         } for
  782.     }ifelse
  783.     (cp\n)print
  784.     (s\n)print            % stroke rect
  785.     end
  786. } i_shortcutOverload
  787.  
  788. /stroke
  789. {
  790.     (n\n) print
  791.     writecurrentcolor
  792.     writecurrentlinewidth
  793.     writecurrentlinecap
  794.     writecurrentlinejoin
  795.     writecurrentdash
  796. %    clipCnt 1 eq 
  797. %        { pathClipForStroke } if
  798.     storeMatrix
  799.  
  800.     {i_move} {i_line} {i_curve} {i_close} pathforall
  801.     (s\n)print            % stroke path
  802.     newpath
  803. } i_shortcutOverload
  804.  
  805. /eofill
  806. {
  807.     (n\n) print            % start polygon
  808.     writecurrentcolor    % write color
  809.     writecurrentlinewidth
  810.     writecurrentlinecap
  811.     writecurrentlinejoin
  812.     writecurrentdash
  813. %    clipCnt 1 eq
  814. %        { pathClipAndClose } if
  815.     storeMatrix            % take transformation, scaling, rotation from PostScript
  816.     {i_move} {i_line} {i_curve} {i_close} pathforall
  817.     (f\n)print            % close polygon
  818.  
  819.     newpath                % clear stack
  820. } i_shortcutOverload
  821.  
  822. /fill 
  823. {
  824.     (fill-winding\n) print
  825.     eofill 
  826.     (fill-evenodd\n) print
  827. } i_shortcutOverload
  828.  
  829. /clip
  830. {
  831.     userdict begin
  832.     (n\n)print            % start clip polygon
  833.  
  834. % FIXME: pathClipAndClose first?
  835.  
  836.     storeMatrix            % take transformation, scaling, rotation from PostScript
  837.     {i_move} {i_line} {i_curve} {i_close} pathforall
  838.  
  839.     (ci\n)print            % close clip polygon begin path
  840.                         % we have to close the path!!
  841. %    clip
  842. %    /clipCnt 1 def
  843.     newpath                % clear stack
  844.     end
  845. } i_shortcutOverload
  846.  
  847. /eoclip
  848. {
  849.     userdict begin
  850.     (n\n)print            % start clip polygon
  851.  
  852. % FIXME: pathClipAndClose first?
  853.  
  854.     storeMatrix            % take transformation, scaling, rotation from PostScript
  855.     {i_move} {i_line} {i_curve} {i_close} pathforall
  856.  
  857.     (ci\n)print            % close clip polygon begin path
  858.                         % we have to close the path!!
  859. %    clip
  860. %    /clipCnt 1 def
  861.     newpath                % clear stack
  862.     end
  863. } i_shortcutOverload
  864.  
  865. % we don't clip
  866. % because this doesn't work for flattening text (show, charpath) with NeXT PostScript Code
  867. /rectclip
  868. {
  869.     % let Scribus decide what to do with ci; was: pop pop pop pop
  870.     userdict begin
  871.     (n\n)print            % start clip polygon
  872.  
  873.     storeMatrix            % take transformation, scaling, rotation from PostScript
  874.     dup type dup /arraytype ne exch /stringtype ne and
  875.     {
  876.         4 copy
  877.         /i_h exch def
  878.         /i_w exch def
  879.         /i_y exch def
  880.         /i_x exch def
  881.         i_x i_y i_move
  882.         i_x i_w add i_y i_line
  883.         i_x i_w add i_y i_h add i_line
  884.         i_x i_y i_h add i_line
  885.     } {
  886.         % array or string
  887.         0 4 dup length 1 sub 
  888.         {
  889.             1 index 1 index get /i_x exch def
  890.             1 add
  891.             1 index 1 index get /i_y exch def
  892.             1 add
  893.             1 index 1 index get /i_w exch def
  894.             1 add
  895.             1 index 1 index get /i_y exch def
  896.             i_x i_y i_move
  897.             i_x i_w add i_y i_line
  898.             i_x i_w add i_y i_h add i_line
  899.             i_x i_y i_h add i_line
  900.         } for
  901.     } ifelse
  902.     
  903.     (ci\n)print            % close clip polygon begin path
  904.                         % we have to close the path!!
  905. %    rectclip
  906. %    /clipCnt 1 def
  907.     newpath                % clear stack
  908.     end
  909. } i_shortcutOverload
  910.  
  911.  
  912. % Code for reading images is currently commented out, as it
  913. % doesn't seem to work correctly.
  914. %    Copyright (C) 1994 Aladdin Enterprises.  All rights reserved.
  915. % This software is provided AS-IS with no warranty, either express or
  916. % implied.
  917. % This software is distributed under license and may not be copied,
  918. % modified or distributed except as expressly authorized under the terms
  919. % of the license contained in the file LICENSE in this distribution.
  920. % For more information about licensing, please refer to
  921. % http://www.ghostscript.com/licensing/. For information on
  922. % commercial licensing, go to http://www.artifex.com/licensing/ or
  923. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  924. % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
  925.  
  926. % $Id: import.prolog 13454 2009-05-08 19:04:32Z jghali $
  927. % traceimg.ps
  928. % Trace the data supplied to the 'image' operator.
  929.  
  930. % This code currently handles only the (Level 2) dictionary form of image,
  931. % with a single data source and 8-bit pixels.
  932.  
  933. % changed for Scribus image import by Andreas Vox, 2006-2-21
  934. % added support for colorimage and other image variant
  935.  
  936. /i_image            % <dict> i_image -
  937. {
  938. %dup { == == } forall
  939. /i_image =
  940.     begin 
  941.         /i_left Width Height mul Decode length 2 idiv mul BitsPerComponent mul 8 idiv dup /i_size exch store store 
  942.         /i_dict currentdict store 
  943.         /i_nsources 1 store 
  944.         /i_source 0 store 
  945.         /i_datasource currentdict /DataSource get store
  946.         currentdict /MultipleDataSources known not 
  947.             { /MultipleDataSources false def } if
  948.         MultipleDataSources
  949.         {
  950.             /i_nsources  DataSource length store
  951.             /i_datasource DataSource 0 get store
  952.         } if
  953.     end
  954.     storeMatrix 
  955.     i_dict /ImageMatrix get matrix invertmatrix matrix currentmatrix matrix concatmatrix /i_m exch def
  956.     i_dict /Width get  0 i_m dtransform dup mul exch dup mul add sqrt /i_w exch def 
  957.     0 i_dict /Height get i_m dtransform dup mul exch dup mul add sqrt /i_h exch def
  958.     0  0 i_m transform  /i_y exch def /i_x exch def 
  959.     i_dict /Width get i_dict /Height get i_m transform
  960.     /i_hflip -1 def /i_vflip 1 def 
  961.     dup i_y le { /i_y exch def } { pop /i_vflip -1 def } ifelse
  962.     dup i_x le { /i_x exch def } { pop /i_hflip  1 def } ifelse
  963.     0 i_dict /Height get i_m dtransform atan
  964.     /i_angle exch def
  965.     (.dat) i_exportfilename
  966.         (im ) print            % im x y w h angle ...
  967.         i_x i_hscale div i_str cvs print ( ) print
  968.         i_y i_vscale div i_str cvs print ( ) print
  969.         i_w i_hscale div i_str cvs print ( ) print
  970.         i_h i_vscale div i_str cvs print ( ) print
  971.         i_angle i_str cvs print ( ) print
  972.         i_dict /Width get  i_str cvs print ( ) print            % ... hpix vpix ...
  973.         i_dict /Height get i_str cvs print ( ) print
  974.         currentcolorspace 0 get /DeviceRGB eq
  975.             { (tiff24nc ) print } 
  976.         { currentcolorspace 0 get /DeviceCMYK eq
  977.             { (psdcmyk ) print } 
  978.         { currentcolorspace 0 get /DeviceGray eq
  979.             { (tiffgray ) print } 
  980.             { (tiff32nc ) print }
  981.         ifelse } ifelse } ifelse
  982.         dup  (.tif) concatenate print (\n) print flush            % ... dev filename
  983.         (.dat) concatenate (w) file /i_file exch store            % temp file
  984.     currentcolorspace ==write ( setcolorspace\n) =write
  985.     (<<\n) =write 
  986.     i_dict { exch
  987.           dup /DataSource eq 
  988.             { pop pop (/DataSource currentfile\n) =write }
  989.           {
  990.             dup /ImageMatrix eq 
  991.                 { pop pop (/ImageMatrix [) =write
  992.                     i_hflip ==write ( 0 0 ) =write i_vflip ==write 
  993.                     ( ) =write 
  994.                     i_hflip 0 lt { i_dict /Width get } { 0 } ifelse ==write 
  995.                     ( ) =write 
  996.                     i_vflip 0 lt { i_dict /Height get} { 0 } ifelse ==write 
  997.                     (]\n) =write }
  998.                 { ==write ( ) =write ==write (\n) =write }
  999.             ifelse 
  1000.           } ifelse 
  1001.         } forall 
  1002.     (>>\nimage\n) =write i_file flushfile
  1003.  
  1004.     { %loop
  1005.       i_left 0 le 
  1006.       { 
  1007.         i_source 1 add /i_source exch def
  1008.         i_source i_nsources ge { exit } if
  1009.         i_dict /DataSource get i_source get /i_datasource exch def
  1010.         /i_left i_size def
  1011.       } if
  1012.       /i_datasource load exec
  1013.       dup type /filetype eq
  1014.        { i_buf 0 i_left 32 .min getinterval readstring pop
  1015.        } if
  1016.       dup length 0 eq {pop i_zero 0 i_left 32 .min getinterval} if
  1017.       dup i_file exch writestring 
  1018.       i_left exch length sub /i_left exch def
  1019.     } loop
  1020.     i_file flushfile
  1021. /i_imageE =
  1022.  } bind def
  1023.  
  1024. /colorimage
  1025. {
  1026. /colorimage =
  1027.     % width height bits/sample matrix datasource0..n-1 multi ncomp
  1028.     /tmpN exch def
  1029.     /tmpMulti exch def
  1030.     tmpMulti
  1031.     {
  1032.         /tmpN load array astore
  1033.     } if
  1034.     /tmpN load 6 add dict
  1035.     dup 7 -1 roll /Width exch put 
  1036.     dup 6 -1 roll /Height exch put 
  1037.     dup 5 -1 roll /BitsPerComponent exch put 
  1038.     dup 4 -1 roll /ImageMatrix exch put 
  1039.     dup 3 -1 roll /DataSource exch put 
  1040.     tmpMulti
  1041.     {
  1042.         dup /MultipleDataSources true put
  1043.     } if
  1044.     dup /ImageType 1 put
  1045.     gsave
  1046.     /tmpN load
  1047.         dup 1 eq
  1048.         {
  1049.             1 index /Decode [0 1] /Decode put
  1050.             /DeviceGray setcolorspace
  1051.         } if
  1052.         dup 3 eq
  1053.         {
  1054.             1 index /Decode [0 1 0 1 0 1] put
  1055.             /DeviceRGB setcolorspace
  1056.         } if
  1057.         dup 4 eq
  1058.         {
  1059.             1 index /Decode [0 1 0 1 0 1 0 1]  put
  1060.             /DeviceCMYK setcolorspace
  1061.         } if
  1062.     pop
  1063.     i_image
  1064.     grestore
  1065. /colorimageE =
  1066. } i_shortcutOverload
  1067.  
  1068. /image {
  1069. /image =
  1070.     gsave
  1071.     dup type /dicttype ne 
  1072.     {
  1073.         % width height bits/sample matrix datasource
  1074.         7 dict
  1075.         dup 7 -1 roll /Width exch put
  1076.         dup 6 -1 roll /Height exch put
  1077.         dup 5 -1 roll /BitsPerComponent  exch put
  1078.         dup 4 -1 roll /ImageMatrix exch put
  1079.         dup 3 -1 roll /DataSource exch put
  1080.         dup 1 /ImageType exch put
  1081.         dup [0 1] /Decode exch put
  1082.         /DeviceGray setcolorspace
  1083.     } if
  1084.     i_image
  1085.     grestore
  1086. /imageE =
  1087. } i_shortcutOverload
  1088.  
  1089. /imagemask
  1090. {
  1091. /imagemask =
  1092.     writecurrentcolor
  1093.     (mask\n) print
  1094.     gsave
  1095.     dup type /dicttype ne 
  1096.     {
  1097.         % width height pol matrix datasource
  1098.         7 dict
  1099.         dup 7 -1 roll /Width exch put
  1100.         dup 6 -1 roll /Height exch put
  1101.         dup 5 -1 roll { [0 1] } { [1 0] } ifelse /Decode exch put
  1102.         dup 4 -1 roll /ImageMatrix exch put
  1103.         dup 3 -1 roll /DataSource exch put
  1104.     } if
  1105.     dup 1 /ImageType exch put
  1106.     dup 1 /BitsPerComponent exch put
  1107.     /DeviceGray setcolorspace
  1108.     i_image
  1109.     grestore
  1110. /imagemaskE =
  1111. } i_shortcutOverload
  1112.  
  1113.  
  1114. % declare some global vars
  1115.  
  1116. /i_left 0 def
  1117. /i_size 0 def
  1118. /i_dict null def
  1119. /i_buf 32 string def
  1120. /i_nsources 1 def
  1121. /i_source 0 def
  1122. /i_datasource { (x) } def
  1123. /i_file null def
  1124. /i_filecount 1 def
  1125. /i_zero 32 string def
  1126.  
  1127. %%%% End of traceimage code
  1128.  
  1129.  
  1130. /stateArray 500 array def
  1131. /stateTop 0 def
  1132. /gsave
  1133. {
  1134.     (gs\n) print
  1135.     userdict begin
  1136. %    (gs\n) print
  1137.     stateArray stateTop gstate currentgstate put
  1138.     /stateTop stateTop 1 add def
  1139.     end
  1140. } i_shortcutOverload
  1141.  
  1142. /grestore
  1143. {
  1144.     (gr\n) print
  1145.     userdict begin
  1146.     stateTop 1 lt
  1147.     {
  1148.     }
  1149.     {
  1150. %        (gr\n) print
  1151.         stateArray stateTop 1 sub get setgstate
  1152.         /stateTop stateTop 1 sub def
  1153.         stateArray stateTop 0 put
  1154.     }ifelse
  1155.     end
  1156. } i_shortcutOverload
  1157.  
  1158. /stringwidth
  1159. {
  1160.     /i_shortcut true store
  1161.     stringwidth
  1162.     /i_shortcut false store
  1163. } i_shortcutOverload
  1164.  
  1165. % a bind def of the show operator doesn't work,
  1166. % so this is our way to get a charpath entry for flattening text
  1167. /root_charpath
  1168. {
  1169.     charpath
  1170. } bind def
  1171.  
  1172. /i_kerningI
  1173. {
  1174.     exch 1 getinterval stringwidth
  1175. } bind def
  1176.  
  1177. % find kerning value
  1178. /i_kerningII        % index string   i_kerning   dx dy 
  1179. {
  1180.     % stringwidth( [n..n+1] ) - stringwidth( [n+1] )
  1181.     /i_pstring exch def
  1182.     /i_pindex exch def
  1183.     i_pstring i_pindex 2 getinterval stringwidth exch    % y2 x2
  1184.     i_pstring i_pindex 1 add 1 getinterval stringwidth        % y2 x2 x1 y1
  1185.     4 1 roll sub                                            % y1 y2 (x2-x1)
  1186.     3 1 roll exch sub                                        % (x2-x1) (y2-y1)
  1187. } bind def
  1188.  
  1189.  
  1190. /i_kerningIII        % index string   i_kerning   dx dy 
  1191. {
  1192.     % stringwidth( [n..n+1] ) - stringwidth( [n+1] )
  1193.     /i_pstring exch def
  1194.     /i_pindex exch def
  1195.     i_pstring i_pindex 2 getinterval (l) exch concatenate stringwidth exch    % y2 x2
  1196.     i_pstring i_pindex 1 add 1 getinterval (l) exch concatenate stringwidth        % y2 x2 x1 y1
  1197.     4 1 roll sub                                            % y1 y2 (x2-x1)
  1198.     3 1 roll exch sub                                        % (x2-x1) (y2-y1)
  1199. } bind def
  1200.  
  1201. /i_kerning /i_kerningII load def
  1202.  
  1203. /show % string show -
  1204.     userdict begin
  1205.     storeMatrix
  1206.     currentfont /FontName known
  1207.     % stack: string
  1208.     {
  1209.         currentfont /FontType get dup 3 eq exch 0 eq or
  1210.         {
  1211.             currentpoint /ycur exch def /xcur exch def
  1212.             currentpoint    % x y
  1213.             newpath
  1214.             /clipCnt 0 def
  1215.             moveto
  1216.             (n\n)print            % start polygon
  1217.             writecurrentcolor    % write color
  1218.             storeMatrix
  1219.             dup
  1220.             stringwidth
  1221.             /curwidthy exch def /curwidthx exch def
  1222.             false root_charpath
  1223.             {i_move} {i_line} {i_curve} {i_close} pathforall
  1224.             (f\n)print            % close polygon
  1225.             newpath
  1226.             curwidthx xcur add curwidthy ycur add moveto
  1227.             currentpoint /ycur exch def /xcur exch def
  1228.             newpath            % clear graphic stack
  1229.             xcur ycur moveto
  1230.         }
  1231.         {
  1232.             currentpoint /ycur exch def /xcur exch def
  1233.             currentpoint    % x y
  1234.             newpath
  1235.             /clipCnt 0 def
  1236.             moveto
  1237.             /completeString exch def
  1238.             % we process each char separately to get smaller paths
  1239.             0 1 completeString length 1 sub
  1240.             {
  1241.                 (n\n)print            % start polygon
  1242.                 writecurrentcolor    % write color
  1243.                 storeMatrix
  1244.                 dup completeString length 1 sub eq 
  1245.                 { dup completeString exch 1 getinterval stringwidth } 
  1246.                 { dup completeString i_kerning } ifelse 
  1247.                 /curwidthy exch def /curwidthx exch def
  1248.                 completeString exch 1 getinterval dup /curstr exch def
  1249.                 false root_charpath
  1250.                 {i_move} {i_line} {i_curve} {i_close} pathforall
  1251.                 (f\n)print            % close polygon
  1252.                 newpath
  1253.                 curwidthx xcur add curwidthy ycur add moveto
  1254.                 currentpoint /ycur exch def /xcur exch def
  1255.                 newpath            % clear graphic stack
  1256.                 xcur ycur moveto
  1257.             } for
  1258.             currentpoint    % x y
  1259.             newpath                % clear graphic stack (and current point)
  1260.             moveto
  1261.         } ifelse
  1262.     } 
  1263.     {
  1264.         currentfont /FontType known
  1265.         {
  1266.             currentfont /FontType get dup 3 eq exch 0 eq or
  1267.             {
  1268.                 currentpoint /ycur exch def /xcur exch def
  1269.                 currentpoint    % x y
  1270.                 newpath
  1271.                 /clipCnt 0 def
  1272.                 moveto
  1273.                 (n\n)print            % start polygon
  1274.                 writecurrentcolor    % write color
  1275.                 storeMatrix
  1276.                 dup
  1277.                 stringwidth
  1278.                 /curwidthy exch def /curwidthx exch def
  1279.                 false root_charpath
  1280.                 {i_move} {i_line} {i_curve} {i_close} pathforall
  1281.                 (f\n)print            % close polygon
  1282.                 newpath
  1283.                 curwidthx xcur add curwidthy ycur add moveto
  1284.                 currentpoint /ycur exch def /xcur exch def
  1285.                 newpath            % clear graphic stack
  1286.                 xcur ycur moveto
  1287.             }
  1288.             {
  1289.                 pop
  1290.             } ifelse
  1291.         } 
  1292.         { 
  1293.             pop
  1294.         } ifelse
  1295.     } ifelse
  1296.     end
  1297. } i_shortcutOverload
  1298.  
  1299. /ashow
  1300. {
  1301.     % ax ay string
  1302.     exch /ydist exch def
  1303.     exch /xdist exch def
  1304.     userdict begin
  1305.     storeMatrix
  1306.     currentfont /FontName known
  1307.     % stack: string
  1308.     {
  1309.         currentpoint /ycur exch def /xcur exch def
  1310.         currentpoint    % x y
  1311.         newpath
  1312.         /clipCnt 0 def
  1313.         moveto
  1314.         /completeString exch def
  1315.         % we process each char separately to get smaller paths
  1316.         0 1 completeString length 1 sub
  1317.         {
  1318.             (n\n)print            % start polygon
  1319.             writecurrentcolor    % write color
  1320.             storeMatrix
  1321.             dup completeString length 1 sub eq 
  1322.             { dup completeString exch 1 getinterval stringwidth } 
  1323.             { dup completeString i_kerning } ifelse 
  1324.             /curwidthy exch def /curwidthx exch def
  1325.             completeString exch 1 getinterval dup /curstr exch def
  1326.             false root_charpath
  1327.             {i_move} {i_line} {i_curve} {i_close} pathforall
  1328.             (f\n)print            % close polygon
  1329.             newpath
  1330.             curwidthx xcur add curwidthy ycur add
  1331.             exch xdist add exch ydist add moveto
  1332.             currentpoint /ycur exch def /xcur exch def
  1333.             newpath            % clear graphic stack
  1334.             xcur ycur moveto
  1335.         } for
  1336.         currentpoint    % x y
  1337.         newpath                % clear graphic stack (and current point)
  1338.         moveto
  1339.     } {
  1340.         pop
  1341.     } ifelse
  1342.     end
  1343. } i_shortcutOverload
  1344.  
  1345. /awidthshow        % cx cy char ax ay string
  1346. {
  1347.     % ax ay string
  1348.     exch /ydist exch def
  1349.     exch /xdist exch def
  1350.     % cx cy char string
  1351.     exch /char exch def
  1352.     exch /cydist exch def
  1353.     exch /cxdist exch def
  1354.     userdict begin
  1355.     storeMatrix
  1356.     currentfont /FontName known
  1357.     % stack: string
  1358.     {
  1359.         currentpoint /ycur exch def /xcur exch def
  1360.         currentpoint    % x y
  1361.         newpath
  1362.         /clipCnt 0 def
  1363.         moveto
  1364.         /completeString exch def
  1365.         % we process each char separately to get smaller paths
  1366.         0 1 completeString length 1 sub
  1367.         {
  1368.             (n\n)print            % start polygon
  1369.             writecurrentcolor    % write color
  1370.             storeMatrix
  1371.             dup completeString length 1 sub eq 
  1372.             { dup completeString exch 1 getinterval stringwidth } 
  1373.             { dup completeString i_kerning } ifelse 
  1374.             /curwidthy exch def /curwidthx exch def
  1375.             completeString exch 1 getinterval dup /curstr exch def
  1376.             false root_charpath
  1377.             {i_move} {i_line} {i_curve} {i_close} pathforall
  1378.             (f\n)print            % close polygon
  1379.             newpath
  1380.             curwidthx xcur add curwidthy ycur add
  1381.             exch xdist add exch ydist add moveto
  1382.             curstr 0 get char eq
  1383.             {
  1384.                 currentpoint exch cxdist add exch cydist add moveto
  1385.             } if
  1386.             currentpoint /ycur exch def /xcur exch def
  1387.             newpath            % clear graphic stack
  1388.             xcur ycur moveto
  1389.         } for
  1390.         currentpoint    % x y
  1391.         newpath                % clear graphic stack (and current point)
  1392.         moveto
  1393.     } {
  1394.         pop
  1395.     } ifelse
  1396.     end
  1397. } i_shortcutOverload
  1398.  
  1399. /widthshow    % cx cy char string
  1400. {
  1401.     0 exch
  1402.     0 exch
  1403.     awidthshow
  1404. } bind def
  1405.  
  1406. %/cshow    % proc string
  1407. %{
  1408. %    exch pop
  1409. %    show
  1410. %} i_shortcutOverload
  1411.  
  1412. /kshow    % proc string
  1413. {
  1414.     dup length 1 sub 
  1415.     dup 0 ne
  1416.     {
  1417.         1 index 0 1 getinterval
  1418.         show
  1419.         1 sub
  1420.         dup 0 ne
  1421.         {
  1422.             1 add
  1423.             1 exch 1 exch
  1424.             {
  1425.                 dup 1 sub
  1426.                 2 index exch get
  1427.                 2 index 2 index get
  1428.                 4 index exec
  1429.                 1 index exch 1 getinterval
  1430.                 show
  1431.             } for
  1432.         } if
  1433.     }
  1434.     {
  1435.         pop dup show
  1436.     } ifelse
  1437.     pop pop
  1438. } i_shortcutOverload
  1439.  
  1440. /xshow    % string array
  1441. {
  1442.     pop %FIXME
  1443.     show
  1444. } i_shortcutOverload
  1445.  
  1446. /xyshow    % string array
  1447. {
  1448.     pop %FIXME
  1449.     show
  1450. } i_shortcutOverload
  1451.  
  1452. /yshow    % string array
  1453. {
  1454.     pop %FIXME
  1455.     show
  1456. } i_shortcutOverload
  1457.  
  1458. /i_reencode % newfontname reencodevector origfontdict -> i_reencode -> newfontdict
  1459. {
  1460.     userdict begin
  1461.  dup begin dup maxlength dict begin
  1462.   { 1 index /FID ne {def} {pop pop} ifelse
  1463.   } forall
  1464.   /Encoding exch def
  1465.   currentdict
  1466.   end end
  1467.   definefont
  1468.     end
  1469. } bind def
  1470.  
  1471. /glyphshow {
  1472.     save % So can reclaim VM from reencoding
  1473.     currentfont /Encoding get dup length array copy dup 0 5 -1 roll put
  1474.     /GlyphShowTempFont exch currentfont i_reencode
  1475.     setfont
  1476.     (\000) show 
  1477.     currentpoint 3 -1 roll % curx cury -save-
  1478.     restore
  1479.     newpath
  1480.     moveto
  1481. } i_shortcutOverload
  1482.  
  1483. /showpage
  1484. {
  1485.     (sp\n) print
  1486. } i_shortcutOverload
  1487.  
  1488.  
  1489.